#include<bits/stdc++.h>
using namespace std;
int t,n,m,l,V,ans,temp;
struct fff{
    int v,a;
    int d;
}g[100005];
int f[100005];
bool vis[100005];
int main(){
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    scanf("%d",&t);
    while(t--){
        ans=0;temp=0;
        scanf("%d%d%d%d",&n,&m,&l,&V);
        for(int i=1;i<=n;i++){
            scanf("%d%d%d",&g[i].d,&g[i].v,&g[i].a);
        }
        for(int i=1;i<=m;i++){
            scanf("%d",&f[i]);
            vis[i]=0;
        }
        f[m+1]=l;
        for(int i=1;i<=n;i++){
            if(g[i].a==0){
                if(g[i].v>V) {
                    int k=lower_bound(f+1,f+2+m,g[i].d)-f;
                    if(k<=m) {
                        ans++;

                    }
                }
            }
            else if(g[i].a>0){
                if(g[i].v>V) {
                    int k=lower_bound(f+1,f+2+m,g[i].d)-f;
                    if(k<=m){
                            ans++;
                    }
                }
                else{
                    int p=(int)floor(double(V*V-g[i].v*g[i].v)/double(1.0)/double(2.0*g[i].a));
                    int k=upper_bound(f+1,f+2+m,g[i].d+p)-f;
                    if(k<=m){
                            ans++;
                    }
                }
            }
            /*else {
                if(g[i].v>V) {
                    int k=0;
                    k=lower_bound(f+1,f+2+m,g[i].d)-f;
                    int p=(int)floor(double(V*V-g[i].v*g[i].v)/double(1.0)/double(2.0*g[i].a));
                    int q=upper_bound(f+1,f+2+m,g[i].d+p)-f;
                    q--;
                    //cout<<i*i<<" "<<k<<" "<<q<<" ";
                    if(k<=q){
                            ans++;
                    }
                }
            }*/
            printf("%d %d",ans,m-1);
        }
    }
    return 0;
}

